package com.tianqi.tools;

import java.util.Set;
import java.util.TreeSet;

import javax.sql.DataSource;

import com.jfinal.plugin.activerecord.generator.MetaBuilder;

public class DiyMetaBuilder extends MetaBuilder {
	
	private Set<String> includedTables = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);

	public DiyMetaBuilder(DataSource dataSource) {
		super(dataSource);
	}
	
	public void addIncludedTable(String... includedTables) {
		if (includedTables != null) {
			for (String table : includedTables) {
				this.includedTables.add(table);
			}
		}
	}

	/**
	 * 反模式，指定要生成实体的表，忽略未指定的表。以少胜多
	 */
	@Override
	protected boolean isSkipTable(String tableName) {
		if ( includedTables.contains(tableName) ) {
			return false;
		} else {
			return true;
		}
	}
	
}
